
import React, { Component } from 'react'
import { Modal, Form, Input, Button, Checkbox } from 'antd';
export class Alert extends Component {
    onFinish = (values) => {
        console.log('Success:', values.username);
        setDataValue(values.username)
        handleOk()
    }
       //提交表单 验证失败执行的函数 
     onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
     };
  render() {
    const {flag,handleOk,handleCancel,obj,setDataValue} =this.props;
    return (
        <div>
        <Modal title="编辑" 
        visible={flag}
         onOk={handleOk}
         onCancel={handleCancel} >
         <Form
             name="basic"
             labelCol={{ span: 8 }}
             wrapperCol={{ span: 16 }}
             //设置表单回显示值
             initialValues={{ username: obj }}
             onFinish={onFinish}
             onFinishFailed={onFinishFailed}
             autoComplete="off"
         >
         <Form.Item
           label="内容"
           name="username"
          
           rules={[
             { required: true, message: '请输入用户名' }
           ]}
         >
           <Input />
 
         </Form.Item>
 
         <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                 <Button type="primary" onClick={handleCancel}>
                     取消
                 </Button>
                 <Button type="primary" htmlType="submit">
                     确认
                 </Button>
         </Form.Item>
       </Form>
       </Modal>
     </div>
    )
  }
}

export default Alert